<template>
  <t-date-range-picker 
    v-model="time" 
    :format="app.time.format()" 
    valueType="Date"
    :disable-date="props.disabledate" 
    @change="onChange" 
  />
</template>
<script setup>
  import { ref } from 'vue'
  import app from '@/app'

  const props = defineProps(['modelValue', 'disabledate', 'type'])
  const emit = defineEmits(['update:modelValue', 'change'])
  const time = ref(props.modelValue)

  const onChange = () => {
    if(props.type == 'time') {
      emit('update:modelValue', app.time.range(time.value))
    } else {
      emit('update:modelValue', time.value)
    }

    emit('change')
  }
</script>